<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <script>
        //创建js对象
        var obj = new Object();
        //给对象添加属性
        obj.name = "张三";
        obj.age = 20;
        obj.phone = "13203923834";
        obj.sex = "男";
        //给对象添加方法
        obj.speak = function (){
            alert("speak");
        }
        // obj.speak();
        // console.log(obj);

        //删除obj对象的电话属性
        delete obj.phone;
        // console.log(obj);

        //得到对象的属性值
       // alert(obj.name + "   "+obj["name"]);

        //遍历对象中的属性名，然后根据属性名，得到属性值
        for(var fieldName in obj){
            console.log("属性名："+fieldName +"   属性值："+obj[fieldName]);
        }

    </script>
</head>
<body>

</body>
</html>